package edu.psu.collegerecommendationhelper.algorithm;

import java.util.ArrayList;
import java.util.List;

import edu.psu.collegerecommendationhelper.model.DemographicInfo;
import edu.psu.collegerecommendationhelper.model.EducationInfo;
import edu.psu.collegerecommendationhelper.model.PreferenceInfo;
import edu.psu.collegerecommendationhelper.model.RecommendationListing;

import weka.core.Instances;




/**
 * 
 * @author cbarone
 * 
 * This class implements the interface to generate a list of recommended colleges 
 * based on user input. The input is passed into the interface and tested against
 * model.
 *
 */
//public class RecommendationEngine implements Runnable{
public class RecommendationEngine {

	private static UserToClassifierTranslator xlate;
	private static RecommendationResults rslt;
	private static ClassifierData data;
	
	
	//Class constructor.
	public RecommendationEngine() {
		xlate = new UserToClassifierTranslator();
		rslt = new RecommendationResults();
	}

    
	//This function tests a user input against a model.
	public void enterUserSelectionsForEvaluation(DemographicInfo demogrInfo,
			EducationInfo edu, PreferenceInfo pref) {
	
    	data = xlate.translateData(demogrInfo, edu, pref);
    	
    	Instances test = xlate.createTestInstances(data);
    	rslt.testUserSelectionAgainstLearnermodel(test);
    	
    }
	
	
	//This function gets a list of recommended colleges based on input from the user.
	public List<RecommendationListing> createListing(DemographicInfo demogrInfo,
			EducationInfo edu, PreferenceInfo pref) {
		
		//Take the user supplied data and store in Classifier array.
		data = xlate.translateData(demogrInfo, edu, pref);
		
		//Get an Instances object from the ClassifierData array
		//to be used on a model.
		Instances test = xlate.createTestInstances(data);
		
		List<RecommendationListing> results = new ArrayList<RecommendationListing>();
		try {
			results = rslt.createRecommendationsFromNearestNeighborSearch(test);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		return results;
	}

	
/*
	public static void main(String[] args) {

	       (new Thread(new RecommendationEngine() )).start();
		}

		@Override
		public void run() {
			DemographicInfo demogrInfo = new DemographicInfo();
			EducationInfo edu = new EducationInfo();
			PreferenceInfo pref = new PreferenceInfo();
			
			demogrInfo.setState("NJ");
			demogrInfo.setRace("white");
			
			edu.setGPA((float) 3.0);
			edu.setCreadSAT((short) 600);
			
			pref.setPubpri("public");
			pref.setSize("1000");
			pref.setLocation("NJ");
			
			createListing(demogrInfo, edu, pref);

			
		}
*/		
}
